Stressed About NoSQL? Relax with CouchDB!
Andy Matthews
@commadelimited
andyMatthews.net
Adobe
Packt
Nettuts
Emma, Inc.
What's CouchDB?
"Apache CouchDB™ is a database that uses JSON for documents, JavaScript for MapReduce indexes, and regular HTTP for its API"
{
  "boy": "mowgli"
}
    
{
    "friends": ["baloo", "bagheera"]
}
    
{
    "first_name": "Shere",
    "last_name": "Khan",
    "email": "me@tigerdirect.org"
}
    
map.js
function(doc){
    emit(doc._id);
}
    
All doc IDs
curl http://local/db/781378
    
A DBA walks into a NoSQL bar, but leaves because he couldn't find a table.
Why CouchDB?
MongoDB Redis Riak RavenDB Cassandra 140+ others
http://nosql-database.org/
Easy
Flexible
JavaScript
Talk to me about CouchDB databases
Eventually consistent document store
a-z 0-9 _$()+-/
Plan ahead
$ demo time
    
Tell me about CouchDB documents
Valid JSON
{
    _id: "60bfff92176f9179c683f892320005d0",
    _rev: "1-4c6114c65e295552ab1019e2b046b10e",
    foo: "bar"
}
    
{
    _id: "user-jesse-fuller-107597",
    _rev: "1-4c692176f9195552ab1019e2b060bfff",
    user:{
        "id": 107597,
        "first_name": "Jesse",
        "last_name": "Fuller",
        "email": "jfuller@ooba.edu"
    }
}
    
Special fields
http://couch:5984/db/user-jesse-fuller-107597
limit < disk space
$ demo time
    
So what are these design docs you keep talking about?
Constantly indexed view
startkey/endkey
stale=ok
include_docs=true
conflicts=true
limit=5
skip=2
$ demo time
    
What if I'm a visual person?
$ demo time
    
Connecting to CouchDB?
CouchDB for Coldfusion
PouchDB.js
Advanced stuff
Database segmentation
Design doc replication
Questions